package Mynet.src.TCP.test3;

import java.io.*;
import java.net.Socket;

/*
客户端：数据来源于文本文件，接收服务器反馈
 */
public class ClientDemo {
    public static void main(String[] args) throws IOException {
        Socket s = new Socket("192.168.146.1", 10002);
        BufferedReader br = new BufferedReader(new FileReader("D:\\javajhx\\my Net\\src\\InetAddress\\InetAddressDemo.java"));
        //封装输出流写数据
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));

        String line;
        while ((line = br.readLine()) != null) {

            bw.write(line);
            bw.newLine();
            bw.flush();
        }
//        System.out.println(11111);

        //自定义结束标记
//        bw.write(886);
//        bw.newLine();
//        bw.flush();

        //public void shutdownOutput()
        s.shutdownOutput();//输出结束

        //接受服务器反馈
        BufferedReader br1 = new BufferedReader(new InputStreamReader(s.getInputStream()));
        String bys = br1.readLine();//等待数据读取
        System.out.println("服务器的反馈：" + bys);

        s.close();
        br.close();
        bw.close();
    }
}
